import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_shop/common/index.dart';
import 'package:flutter_shop/common/res/strings_zh.dart';
import 'package:flutter_shop/pages/address_page.dart';
import 'package:flutter_shop/provide/address_provider.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import './pages/index_page.dart';
import './provide/child_category_provider.dart';
import './provide/category_goods_list_provider.dart';
import './provide/details_info_provider.dart';
import './provide/cart_provider.dart';
import './provide/current_index_provider.dart';
import 'package:fluro/fluro.dart';
import './routers/routes.dart';
import './routers/application.dart';

void main() {

  runApp(OverlaySupport(
      child: MultiProvider(providers: [
    ChangeNotifierProvider(create: (_) => ChildCategoryProvider()),
    ChangeNotifierProvider(create: (_) => CategoryGoodsListProvider()),
    ChangeNotifierProvider(create: (_) => DetailsInfoProvider()),
    ChangeNotifierProvider(create: (_) => CartProvider()),
    ChangeNotifierProvider(create: (_) => CurrentIndexProvider()),
    ChangeNotifierProvider(create: (_) => AddressProvider()),
  ], child: MyApp())));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final router = Router();
    Routes.configureRoutes(router);
    Application.router = router;

    return Container(
      child: MaterialApp(
          title: StringsZh().appName,
          debugShowCheckedModeBanner: false,
          onGenerateRoute: Application.router.generator,
          theme: ThemeData(
            primaryColor: Colors.purple,
          ),
          home: IndexPage()),
    );
  }
}
